package com.training.java.core.collections.car.pre15;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * Created multiple objects and adding them to List( generic code) List accepts
 * duplicate values. List accepts nulls Maintains the order
 * 
 * @author Satya
 */
public class LapTopListDemo {

	public static void main(String[] args) {

		{

			LapTop laptop1 = new LapTop("IBM", "lenove", "intel core",
					"Windows 32");
			LapTop laptop2 = new LapTop("Dell", "inspiron", "Quad core",
					"Windows 64");
			LapTop laptop3 = new LapTop("Acer", "aspire", "Dual core", "Linux");
			LapTop laptop4 = new LapTop();
			// Same object with different Object Name
			LapTop laptop5 = new LapTop("Acer", "aspire", "Dual core", "Linux");

			// instantiating

			List listOfLapTops = new ArrayList();
			// adding the objects to the list

			listOfLapTops.add(laptop1);
			listOfLapTops.add(laptop2);
			listOfLapTops.add(laptop3);
			// listOfLapTops.add(null);//adding null
			listOfLapTops.add(laptop4);
			listOfLapTops.add(laptop5);// Same object with different Object Name
			listOfLapTops.add(laptop2);// adding duplicate

			// Iterator

			Iterator ite = listOfLapTops.iterator();

			while (ite.hasNext()) {
				LapTop laptop = (LapTop) ite.next();

				System.out.println("company: " + laptop.getCompany());
				System.out.println("model: " + laptop.getModel());
				System.out.println("processor: " + laptop.getProcessor());
				System.out.println("OS: " + laptop.getOs());
				System.out.println("*************************");

			}

		}
	}
}
